﻿using System;
using System.Collections.Generic;
using Framework;

namespace Enterprise.Admin.Handle.Video
{
    public partial class GetListJson : AdminBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var datas = new List<object>();
            var name = Fq("CoName").SafeToString();
            var VideoCategoryId = Fq("CoVideoCategoryId").SafeToInt();
            var language = Fq("CoLanguage").SafeToString();
            var pageValue = Fq("page").SafeToInt();
            var rowsValue = Fq("rows").SafeToInt();
            var videoService = new VideoService();
            var table = videoService.GetTable(name, VideoCategoryId, language, pageValue, rowsValue);
            object result = new { total = table.Total, rows = datas };
            for (int i = 0; i < table.Rows.Count; i++)
            {
                datas.Add(new
                {
                    id = table.Rows[i]["CoVideoId"].SafeToInt(),
                    CoName = table.Rows[i]["CoName"].SafeToString(),
                    CoVideoCategoryId = table.Rows[i]["CoVideoCategoryId"].SafeToInt(),
                    CoIsRecommend = table.Rows[i]["CoIsRecommend"].SafeToBool(),
                    CoIsPopular = table.Rows[i]["CoIsPopular"].SafeToBool(),
                    CoIsTop = table.Rows[i]["CoIsTop"].SafeToBool(),
                    CoViews = table.Rows[i]["CoViews"].SafeToInt(),
                    CoAuthor = table.Rows[i]["CoAuthor"].SafeToString(),
                    CoDate = table.Rows[i]["CoDate"].SafeToDateTime(),
                    CoIsReserved = table.Rows[i]["CoIsReserved"].SafeToBool(),
                    CoReservedUrl = table.Rows[i]["CoReservedUrl"].SafeToString(),
                    CoCategoryName = table.Rows[i]["CoCategoryName"].SafeToString(),
                    CoLanguage = table.Rows[i]["CoLanguage"].SafeToString(),
                    CoNormalImage = table.Rows[i]["CoNormalImage"].SafeToString(),
                    CoSmallImage = table.Rows[i]["CoSmallImage"].SafeToString(),
                    CoBigImage = table.Rows[i]["CoBigImage"].SafeToString()
                });
            }
            Json(result);
        }
    }
}